/**
 */
package webApplication.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import webApplication.WebApplication;
import webApplication.WebApplicationPackage;
import webApplication.WebPage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Web Application</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link webApplication.impl.WebApplicationImpl#getNameApplication <em>Name Application</em>}</li>
 *   <li>{@link webApplication.impl.WebApplicationImpl#getPages <em>Pages</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WebApplicationImpl extends MinimalEObjectImpl.Container implements WebApplication {
	/**
	 * The default value of the '{@link #getNameApplication() <em>Name Application</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNameApplication()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_APPLICATION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNameApplication() <em>Name Application</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNameApplication()
	 * @generated
	 * @ordered
	 */
	protected String nameApplication = NAME_APPLICATION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPages() <em>Pages</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPages()
	 * @generated
	 * @ordered
	 */
	protected EList<WebPage> pages;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WebApplicationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WebApplicationPackage.Literals.WEB_APPLICATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNameApplication() {
		return nameApplication;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNameApplication(String newNameApplication) {
		String oldNameApplication = nameApplication;
		nameApplication = newNameApplication;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WebApplicationPackage.WEB_APPLICATION__NAME_APPLICATION, oldNameApplication, nameApplication));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<WebPage> getPages() {
		if (pages == null) {
			pages = new EObjectContainmentEList<WebPage>(WebPage.class, this, WebApplicationPackage.WEB_APPLICATION__PAGES);
		}
		return pages;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case WebApplicationPackage.WEB_APPLICATION__PAGES:
				return ((InternalEList<?>)getPages()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WebApplicationPackage.WEB_APPLICATION__NAME_APPLICATION:
				return getNameApplication();
			case WebApplicationPackage.WEB_APPLICATION__PAGES:
				return getPages();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WebApplicationPackage.WEB_APPLICATION__NAME_APPLICATION:
				setNameApplication((String)newValue);
				return;
			case WebApplicationPackage.WEB_APPLICATION__PAGES:
				getPages().clear();
				getPages().addAll((Collection<? extends WebPage>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WebApplicationPackage.WEB_APPLICATION__NAME_APPLICATION:
				setNameApplication(NAME_APPLICATION_EDEFAULT);
				return;
			case WebApplicationPackage.WEB_APPLICATION__PAGES:
				getPages().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WebApplicationPackage.WEB_APPLICATION__NAME_APPLICATION:
				return NAME_APPLICATION_EDEFAULT == null ? nameApplication != null : !NAME_APPLICATION_EDEFAULT.equals(nameApplication);
			case WebApplicationPackage.WEB_APPLICATION__PAGES:
				return pages != null && !pages.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (nameApplication: ");
		result.append(nameApplication);
		result.append(')');
		return result.toString();
	}

} //WebApplicationImpl
